package com.chnbst.bstyun.core.common.email;

public class EmailUtil {
	
	private final static String REGISTER_ADDRESS = "register@bstyun.com";
	private final static String PASSWORD = "tdLDW2gNtaFgA9TI";
	private final static String USER_NAME = "百顺通科技";
	private final static String SERVER_HOST = "mail.bstyun.com";
	private final static String SERVER_PORT = "25";
	
	private static MailSenderInfo mailInfo = new MailSenderInfo(); 
	
	static{
		mailInfo.setMailServerHost(SERVER_HOST);
		mailInfo.setMailServerPort(SERVER_PORT);
		mailInfo.setPassword(PASSWORD);
		mailInfo.setNickName(USER_NAME);
		mailInfo.setFromAddress(REGISTER_ADDRESS);
		mailInfo.setUserName(USER_NAME);
		mailInfo.setValidate(true);
	}
	
	public static boolean sendMail(String toAddress,String subject,String content){
		String[] str = toAddress.split("\\|");
		mailInfo.setToAddress(str);
		mailInfo.setSubject(subject);
		mailInfo.setContent(content);
		return SimpleMailSender.sendHtmlMail(mailInfo);
	}
	
	public static void main(String[] args) {
		String str = "尊敬的<b>s1</b>，您好,恭喜您开通了<b>s2</b>！<br>测试哦";
		str = str.replace("s1", "745214429@qq.com").replace("s2", "MC公有云");
		String toAddress = "745214429@qq.com";//664516565@qq.com
		System.out.println(EmailUtil.sendMail(toAddress, "开通通知", str));
	}
}
